package com.shujia.tf

import org.apache.flink.api.common.functions.FilterFunction
import org.apache.flink.streaming.api.scala._

object Demo4Filter {

  def main(args: Array[String]): Unit = {

    val env: StreamExecutionEnvironment = StreamExecutionEnvironment.getExecutionEnvironment

    val ds: DataStream[Int] = env.fromCollection(List(1, 2, 3, 4, 5, 6, 7, 8))


    //scala 方式
    val ds1: DataStream[Int] = ds.filter(i => i % 2 == 1)


    //java 方式
    val ds2: DataStream[Int] = ds.filter(new FilterFunction[Int] {
      override def filter(value: Int): Boolean = {
        value % 2 == 1
      }
    })

    ds2.print()

    env.execute()


  }

}
